﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

[RequireComponent(typeof(ParticleSystem))]
public class ParticleEventListener : MonoBehaviour
{
    [CompilerGenerated]
    private static Action<ParticleCollisionEvent> <>f__am$cache4;
    private List<ParticleCollisionEvent> evts;
    public Action<ParticleCollisionEvent> onParticleCollision;
    private ParticleEventListener[] parentListeners;
    private ParticleSystem ps;

    public ParticleEventListener()
    {
        if (<>f__am$cache4 == null)
        {
            <>f__am$cache4 = new Action<ParticleCollisionEvent>(ParticleEventListener.<onParticleCollision>m__153);
        }
        this.onParticleCollision = <>f__am$cache4;
        this.evts = new List<ParticleCollisionEvent>();
    }

    [CompilerGenerated]
    private static void <onParticleCollision>m__153(ParticleCollisionEvent c)
    {
    }

    private void Awake()
    {
        this.ps = base.GetComponent<ParticleSystem>();
    }

    private void OnParticleCollision(GameObject other)
    {
        int num = this.ps.GetCollisionEvents(other, this.evts);
        for (int i = 0; i < num; i++)
        {
            foreach (ParticleEventListener listener in this.parentListeners)
            {
                if (listener.onParticleCollision != null)
                {
                    listener.onParticleCollision(this.evts[i]);
                }
            }
            this.onParticleCollision(this.evts[i]);
        }
    }

    private void Start()
    {
        this.parentListeners = base.GetComponentsInParent<ParticleEventListener>();
    }
}

